#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2024/9/6 11:11
# @File           : feature
# @IDE            : PyCharm
# @desc           : 描述

from sqlalchemy.orm import Mapped, mapped_column
from db.db_base import AuditModel
from sqlalchemy import String, Boolean, UniqueConstraint, Integer


class DCSampleGroup(AuditModel):
    __tablename__ = "dc_check_sample_group"
    __table_args__ = ({'comment': 'QAR抽样规范模型组'})

    group_name: Mapped[str] = mapped_column(String(40), comment="组名称")
    min_value: Mapped[int] = mapped_column(Integer, nullable=True, comment="最小值")
    max_value: Mapped[int] = mapped_column(Integer, nullable=True, comment="最大值")
    value: Mapped[int] = mapped_column(Integer, comment="实际值")

    order: Mapped[int] = mapped_column(Integer, default=0, comment="排序")
    is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")


class DCSampleStandard(AuditModel):
    __tablename__ = "dc_check_sample_standard"
    __table_args__ = (
        UniqueConstraint('standard', 'group_name', name="Idx_Sample_Standard_Group"),
        {'comment': 'QAR抽样规范'}
    )

    standard: Mapped[str] = mapped_column(String(100), comment="件号规范")
    is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")

    group_name: Mapped[str] = mapped_column(String(40), comment="抽样模型组名")
